package cpr.command;

import java.util.List;

import cpr.DefaultCommandHandler;

public class CmdRedo extends DefaultCommandHandler {
	public CmdRedo() {
		super("last","repeats last command",null,null);
		setStartInSeparateThread(false);
	}
	public void execute(String[] params) {
		List hist= getCommandContext().getHistory();
		int ptr = hist.size()-1;
		String cmd = (String)hist.get(ptr);
		while ((cmd!=null)&&cmd.startsWith(getName())) {
			ptr--;
			cmd = (String)hist.get(ptr);
		}
		if (cmd!=null) {
		
			getCommandContext().execute(cmd);
		}
	}

}
